#pragma once
#include <windows.h>
#include <thread>
#include <iostream>
#include "TunRing.h"

using WintunSendCallback = std::function<void (uint8_t* data,uint32_t size)>;

class Wintun
{
public:
	Wintun(const std::wstring& device_id);
	~Wintun();
	bool start();
private:
	bool registerRingBuffers();
	int getAdapterIndex();
	int addIPAddress(const char *ip, const char *mask);
	uint32_t getMetric1(int index);
	int addRoute(const char* ip, const char* mask, const char* gateway);
	HANDLE handle_wintun_;
	tun_ring* receive_ring_;
	tun_ring* send_ring_;
	HANDLE receive_event_;
	HANDLE send_event_ ;
	std::thread thread_read_;
	std::thread thread_write_;
	std::wstring device_id_;
};

